<div class="easyui-panel" title="学生管理" data-options="fit:true" style="display: flex;flex-direction: column;">
	<p style="flex-grow: 0;">
		<label>选择班级：</label>
		<input class="easyui-combobox" data-options="
			url:'banji/list',
			valueField:'id',
			textField:'name',
			panelHeight: 200,
			editable:false,
			icons:[{
		        iconCls:'icon-clear',
		        handler: function(e){
		        	$(e.data.target).textbox('clear');
		        	$('#div').hide();
		    	}
		    }],
			onChange:function(id){
				var grid=$('#stugrid');
				var options=grid.datagrid('options');
				options.url='student/page?classId='+id;
				options.dialog.add.href='student/edit?classId='+id;
				options.dialog.edit.href='student/edit?classId='+id;
				$('#div').show();
				grid.datagrid(options);
			}
		"/>
	</p>
	<div id="div" style="flex-grow: 1; display: none; ">
		<table id="stugrid">
			<thead>
				<tr>
					<th width="200" data-options="field:'stuNo'">学号</th>
					<th width="200" data-options="field:'name'">姓名</th>
				</tr>
			</thead>
		</table>
	</div>
</div>
<script type="text/javascript">
	var grid=$('#stugrid');
	grid.datagrid({
		idField:'id',
		url: 'student/page',
		fit:true,
		fitColumns:true,
		singleSelect:true,
		//rownumbers:true,
		pagination:true,
		pageSize:10,
		sortName:'id',
		pageList:[10,25,50,100],
		toolbar:[$.crudgrid.buttons.add,'-',$.crudgrid.buttons.edit,'-',$.crudgrid.buttons.remove,'-',$.crudgrid.buttons.search,'-',{
			iconCls:'icon-redo',
			text:'密码重置',
			handler:function(){
				var grid=$.crudgrid.grid(this);
				var row = grid.datagrid('getSelected');
				if(!row){
					$.messager.alert('提示','请选择一行数据，再进行此操作...','warning');
					return;
				}
				$.post('student/resetPwd',{id:row.id},function(result){
					$.messager.show({title:'提示',msg:result.msg});
				})
			}
		},'-',$.crudgrid.buttons.refresh,'-'],
		dialog:{
			add:{
				title:'新增',
				href:'student/edit',
				action:'student/save'
			},
			edit:{
				title:'修改',
				href:'student/edit',
				action:'student/save'
			},
			search:{
				title:'查询',
				href:'student/search'
			},
			remove:{
				url:'student/delete',
				msg:'是否要删除这条记录？'
			}
		}
	})
</script>